package ynu.edu.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import ynu.edu.po.Business;
import ynu.edu.service.IBusinessService;

import java.util.List;

@RestController
@RequestMapping(value = "/business")
@Tag(name = "商家服务")
public class BusinessController {
    @Resource
    private IBusinessService businessService;

    @PostMapping("/listBusinessByOrderTypeId")
    @Operation(summary = "查询商家信息",
            description = "根据点餐分类编号查询所属商家信息")
    @Parameter(name = "orderTypeId", description = "点餐分类编号")
    public List<Business> listBusinessByOrderTypeId(@RequestParam Integer orderTypeId) {
        return businessService.listBusinessByOrderTypeId(orderTypeId);
    }

    @PostMapping("/getBusinessById")
    @Operation(summary = "查询商家信息",
            description = "根据商家编号查询商家信息")
    @Parameter(name = "businessId", description = "商家编号")
    public Business getBusinessById(@RequestParam Integer businessId) {
        return businessService.getBusinessById(businessId);
    }

    @GetMapping("/listAllBusiness")
    @Operation(summary = "查询所有商家信息")
    public List<Business> listAllBusiness(){
        return businessService.listAllBusiness();
    }

}
